@extends('WShop::layout')
@section('content')
    @include('WShop::public.header')
    <div class="mui-content mui-scroll-wrapper" id="pullrefresh">
        <div class="mui-scroll">

            <div class="mui-table-view mui-table-view-chevron mui-bottom">
                <div class="mui-queren-dingdan ">
                    <form id="order-pay" action="{{url()->current()}}" method="post">
                        {{csrf_field()}}
                        <ul class="mui-table-view bg-fff">

                            <li style="background: #f2f2f2;height: 10px;"></li>
                            <li class="mui-table-view-cell time">
                                <div class="mui-dingdan-xx bg-fff flex">
                                    <div class="mui-pull-right mui-text-center mui-text-red">
                                        ￥<span style="font-size: 40px;">{{$order->pay_price}}</span>
                                        <em style="font-size: 12px;color: darkgoldenrod">
                                            @if($pay_type == 101)
                                                {{get_currency()['money1']}}
                                            @elseif($pay_type == 102)
                                                {{get_currency()['money2']}}
                                            @elseif($pay_type == 103)
                                                {{get_currency()['money3']}}
                                            @endif
                                        </em>
                                    </div>

                                </div>
                            </li></ul>

                        <ul class="mui-table-view bg-fff">
                             @switch($pay_type)
                              @case(101)
                                <li class="mui-table-view-cell">
                                    <a href="javascript:;" style="color: coral;" >
                                        余额<em style="float: right">{{$wallet->money1}}</em>
                                    </a>
                                </li>
                              @break
                                @case(102)
                                <li class="mui-table-view-cell">
                                    <a href="javascript:;" style="color: coral;">
                                        余额<em style="float: right">{{$wallet->money2}}</em>
                                    </a>
                                </li>
                                @break
                                @case(103)
                                <li class="mui-table-view-cell">
                                    <a href="javascript:;" style="color: coral;" >
                                        余额<em style="float: right">{{$wallet->money3}}</em>
                                    </a>
                                </li>
                                @break
                             @endswitch
                         </ul>
                        <ul class="mui-table-view mui-table-view-radio bg-fff zhifu" style="margin-top: 0;">
                            <div class="mui-input-row">
                                <input style="background: #fff;border: none;padding: 5px 15px;float: initial; width: 100%;font-size: 13px;" type="password" placeholder="请输入您的支付密码" name="pay_pwd" value="">
                            </div>
                        </ul>
                    </form>
                </div>
            </div>
        </div>
    </div>
    <div class="footer1 flex">
        <div class="footer1-left flex-item" >
            <div class="footer1-left-icon" id="btn_Tab_GoPingdan">
                <a href='javascript:;' class="footer1-left-money">确认支付</a>
            </div>
        </div>
    </div>
@endsection
@push('scripts')
<script>
    document.getElementById("btn_Tab_GoPingdan").addEventListener("tap", function() {
        mui.confirm('确认支付订单？','',function(e){
            if(e.index==1){
                var load =  layer.open({type: 2});
                var url = $('#order-pay').attr('action');
                $.ajax({
                    type: 'post',
                    url: url,
                    dataType: 'json',
                    data: $('#order-pay').serialize()
                }).done(function (response) {
                    if(response.status){
                        tooltips(response.msg,6);
                        setTimeout(function () {
                            location.href = response.url;
                        }, 2000);
                    }else{
                        tooltips(response.msg,5);
                    }
                }).fail(function (XMLHttpRequest) {
                    if (XMLHttpRequest.status == 422) {
                        var errors = XMLHttpRequest.responseJSON.errors;
                        if(typeof errors == 'object') {
                            for (var index in errors) { // 不推荐这样
                                tooltips(errors[index][0]);
                                break;
                            }
                        }else{
                            tooltips(XMLHttpRequest.responseJSON.msg);

                        }
                    }else{
                        tooltips('网络异常,请检查连接');
                    }

                }).always(function () {
                    layer.close(load);
                });

                function tooltips(msg) {
                    mui.toast(msg);
                }
            }
        })
    });
</script>
@endpush